*** JPART Cook, An, and Favero (2019) Replication File
*** Reference: "Beyond Policy Diffusion: Spatial Econometric Models of Public Administration"
*** DOI: 


version 15

clear

***specify your working folder

cd "your-working-folder-location where you unzip the material"


/*------------------------------------------------------------------------
PART I: cross-sectional (CS) application
Data source: 
1) TEA snapshot 2015 (base data) 
2) PEIMS Single File Financial Actual Data 2015 (contracting measure)
3) School district shape file provided by TEA
------------------------------------------------------------------------*/

*------------------unzip the Texas school district shape files

unzipfile shapefile_district.zip, replace


*------------------translate shapefile to Stata format

spshape2dta Current_Districts, replace
use Current_Districts.dta, clear


*------------------declare spatial data

spset DISTRICT_N, modify replace


*------------------load cross-sectional data

use JPART_ED_CS.dta, clear


*------------------label variables

label var pcont "% budget contracted"
label var pbilexp "% bilingual expenditures"
label var lnblin "% bilingual expenditures (logged)"
label var enrolk "Enrollment (K)"
label var tturn "Teacher turnover"
label var revk "Revenue per pupil (K)"
label var plocfund "Percentage local fund"
label var pcentadmin "% central administrator"
label var pbstud "% Black student"
label var phstud "% Hispanic student"
label var plowstud "% low-income student"
label var pesl "% English limited proficiency"


*------------------merge CS data with the geographic information

merge 1:1 DISTRICT_N using Current_Districts.dta, keep(match) nogenerate


*------------------create a geographic binary queen contiguity matrix

spmatrix clear
spmatrix create contiguity W_cont 
spmatrix dir

save local_moran.dta, replace //save geographic information for Footnote 19.


*------------------Table 2. Moran test results for spatial dependence in budgetary decisions on bilingual program expenditures.

reg pbilexp
estat moran, errorlag(W_cont) 

reg pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl
estat moran, errorlag(W_cont) 
*Note: Local moran test results in footnote XX are listed at the end of this do-file

*------------------Table 3. Moran test results for spatial dependence in budgetary decisions on bilingual program expenditures.

*Model 1: NS
reg pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, robust
*Model 2: SEM
spregress pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls errorlag(W_cont)
*Model 3: SAR
spregress pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls dvarlag(W_cont) 
*Model 4: SLX
spregress pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls ivarlag(W_cont: revk pbstud phstud plowstud pesl)
*Model 5: SDEM
spregress pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls errorlag(W_cont) ivarlag(W_cont: revk pbstud phstud plowstud pesl)


*------------------Table 4. Total, direct, and indirect effects of SAR, SLX, and SDEM

*SAR
spregress  pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls dvarlag(W_cont) 
estat impact
*SLX
spregress  pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls ivarlag(W_cont: revk pbstud phstud plowstud pesl)
estat impact
*SDEM
spregress  pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls errorlag(W_cont) ivarlag(W_cont: revk pbstud phstud plowstud pesl)
estat impact


*------------------Figure 2. Bilingual education expenditures (%) in Texas school districts, FY2015-16

grmap pbilexp


*------------------Table A1. Summary statistics of the CS data set: 1,005 Texas school districts in 2016.

sum pbilexp enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl


*------------------Table OA1. Determinants of bilingual education expenditures (logged), Texas FY 2015-16. 

*Model 1: NS
reg lnblin enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, robust
*Model 2: SEM
spregress lnblin enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls errorlag(W_cont)
*Model 3: SAR
spregress lnblin enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls dvarlag(W_cont) 
*Model 4: SLX
spregress lnblin enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls ivarlag(W_cont: revk pbstud phstud plowstud pesl)
*Model 5: SDEM
spregress lnblin enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl, gs2sls errorlag(W_cont) ivarlag(W_cont: revk pbstud phstud plowstud pesl)


*------------------Footnote 13. Moran test results for spatial dependence in percent budget contracted

reg pcont
estat moran, errorlag(W_cont) 

reg pcont enrolk tturn revk plocfund pcentadmin pbstud phstud plowstud pesl
estat moran, errorlag(W_cont) 


/*------------------------------------------------------------------------
PART II: time-series-cross-sectional (TSCS) application
Data source: 
1) Zhu, Ling 2013. "Panel Data Analysis in Public Administration." JPART
2) State shape files are extracted from the GADM database (www.gadm.org)

*The authors appreciate Ling Zhu for sharing her data with us. 
------------------------------------------------------------------------*/

clear


*------------------unzip the state shape file

unzipfile USA_adm_shp.zip, replace


*------------------translate the shapefile to Stata format

spshape2dta USA_adm1.shp, replace 


*------------------declare spatial data

use USA_adm1.dta, clear 
gen state = NAME_1
duplicates drop ID_1, force
spcompress, force
spset ID_1, modify replace 


*------------------load TSCS data

use "JPART_HEALTH_TSCS.dta", clear


*------------------label variables

label var uninsured "% Uninsured"
label var eligibility "Medicaid eligibility"
label var l2finance "L2. Public finance"
label var ownership "Public ownership"
label var stateliberal "State liberalism"
label var unemp "Unemployment"
label var poverty "Poverty"
label var black "Black population"
label var latino "Latino population"
label var aged "Aged population"
label var obesity "Obesity rate"
label var poorhealth "Perceived poor health"
label var luninsured "L1. % Uninsured"
           

*------------------merge TSCS data with geographic information		   

merge m:1 state using USA_adm1, keep(match) nogenerate


*------------------create a queen binary contiguity matrix

xtset ID_1 year
spbalance, balance  
spmatrix clear
spmatrix create contig W_cont if year == 1992
spmatrix dir


*------------------Table 5. Determinants of state-level uninsured rates, 1992 to 2006 – Static & RE  

*Model 1: NS
reg uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth
*Model 2: SEM
spxtregress uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth, re sarpanel errorlag(W_cont)
*Model 3: SAR
spxtregress uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth, re sarpanel dvarlag(W_cont)
*Model 4: SAC
spxtregress uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth, re sarpanel dvarlag(W_cont) errorlag(W_cont)


*------------------Table 6. Determinants of state-level uninsured rates, 1992 to 2006 – Dynamic & RE 

*Model 1: NS
reg uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth luninsured
*Model 2: SEM
spxtregress uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth luninsured, re sarpanel errorlag(W_cont)
*Model 3: SAR
spxtregress uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth luninsured, re sarpanel dvarlag(W_cont)
*Model 4: SAC
spxtregress uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth luninsured, re sarpanel dvarlag(W_cont) errorlag(W_cont) 


*------------------Table A2.  Summary statistics of the TSCS data set: 50 states from 1992 to 2006.

sum uninsured eligibility l2finance ownership stateliberal unemp poverty black latino aged obesity poorhealth year 


*------------------Footnote 19. Local moran test results for spatial dependence in budgetary decisions on bilingual program expenditures.

clear

*------------------install spatwmat and spmat user-written packages first
findit spatwmat
findit spmat

shp2dta using Current_Districts, database(CD) coordinates(CD_coord) replace
use local_moran, clear
spmat contiguity C1 using CD_coord, id(FID) normalize(spec) replace 
spmat export C1 using contig.txt, noid replace
insheet using contig.txt, delim(" ") clear
drop in 1
save contig.dta, replace

use local_moran, clear

set matsize 11000

spatwmat using contig.dta, name(W) standardize eigenval(E)	
spatlsa pbilexp, w(W) graph(moran) sort moran id(distname) two symbol(id)
